package lib.wzh.com.libcore.framework.base;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lib.wzh.com.libcore.framework.chain.ReturnBuilder;
import lib.wzh.com.libcore.framework.enums.ResponseEnum;
import lib.wzh.com.libcore.framework.interfaces.BaseEnum;
import lib.wzh.com.libcore.framework.response.BasePageResponse;
import lib.wzh.com.libcore.framework.response.BaseResponse;

/**
 * @Author lib
 * @Date 2021/11/23 16:02
 * @ClassName BaseController
 * @Version v1.0
 */

public class BaseController {

    public <T> BaseResponse<T> ok(T data){
        return ReturnBuilder.execute(data);
    }

    public <T> BaseResponse<T> R(BaseEnum baseEnum){
        return new BaseResponse<>(baseEnum);
    }

    public <T> BaseResponse<T> notOk(T data){
        return new BaseResponse<>(ResponseEnum.FAIL.code(), ResponseEnum.FAIL.msg(), ResponseEnum.FAIL.success(), data);
    }

    public <T> BasePageResponse<T> pageOk(IPage<T> page){
        return new BasePageResponse<>(page);
    }

    public <T> BasePageResponse<T> pageNotOk(String error){
        return new BasePageResponse<>(error);
    }

}
